
#ifndef OpearteBmp_h__
#define OpearteBmp_h__



#include <math.h>
#include <time.h>

#define KColorPaletteCount	256

#define RAD					0.0174532925

const int offsetXsize = 15;
const int offsetYsize = 20;

class OperateBmp
{
public:
	OperateBmp(const HDC& aHDC,int aWidth,int aHeight);
	~OperateBmp(void);


	void Draw(const HDC& aHDC);
	void Move();

	void SetBackgroundBitmap(HBITMAP aHBitmap);

	void ReadBmp(const char* aFileName);
private:

	void RelaseBitmapBuffer();
	void CreateBitmapBuffer(const HDC& aHDC);

	void DrawLine(ULONG *buffer,const POINT& aPoint, const POINT& bPoint);
	void DrawLine(ULONG *buffer,int x1,int y1 ,int x2,int y2);

	void DrawFromRect(ULONG *buffer,const ULONG *src,int x1,int y1 ,int x2,int y2);

	inline void SetPointColor(ULONG& val,const ULONG& aColor);

private: //color
	ULONG iColorPalette[KColorPaletteCount];
	ULONG *iColorBuffer1,*iColorBuffer2;
	int *iCoolMap,*iCoolMapBuffer;
	int iShiftSize;
	void InitColorPalette();
	void DrawColorOnBitmap(ULONG* aIndex);
	void DeclineToTop();

	void Smooth1(ULONG *aData,int height ,int width );
	void Smooth2(ULONG *aData,int height ,int width );
	void Smooth( int *aData );

	void Burn(ULONG *src,ULONG *dest,int startline,int length);
	void ShiftCoolMap();

private: // bitmap
	BITMAPINFO iBitmapInfo;
	HBITMAP iHBitmap;
	HBITMAP iHBackgroundBitmap;
	int iWidth,iHeight,iSize;
	ULONG * iBitmapData;
	

	ULONG *iBackgroundData;


private:

	void InitGelly();
	void Relax();
	void TextureWarp();
	void TextureBlock(int xo,int yo);



	struct PARTICLE
	{
		float x,y,xv,yv,c;
	}offset[offsetXsize][offsetYsize];

	int way;

};

#endif // OpearteBmp_h__
